package com.foreknow.demo7;

public class Y extends X {

    private String school;

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    //方法重写(覆盖)：1.要有继承关系  2.子类可以重写父类的方法(规则：方法的名称、参数、返回值类型都相同)
    public void showInfo() {
        System.out.println("姓名：" + this.getName() + "\t年龄：" + this.getAge() + "\n所在学校：" + this.getSchool());
    }

    public static void main(String[] args) {
        Y y = new Y();
        y.setName("tom");
        y.setAge(16);
        y.setSchool("foreknow");
        y.showInfo();
    }

}















